/*************************************************************************
> File Name: hanoi.c
> Author: icebear
> Mail: 3322366195@qq.com
> Created Time: 2023-07-31 11:21:47
> Description: 汉诺塔
************************************************************************/

#include <stdio.h>
void move(char x, char y);
void hanoi(int count, char a, char b, char c);

int main(int argc, char const *argv[])
{
    char a = 'A', b = 'B', c = 'C';
    printf("hanoi 3\n");
    hanoi(3, a, b, c);
    return 0;
}
void hanoi(int count, char a, char b, char c)
{
    if (count == 1)
    {
        move(a, c); // 如果只有一个盘子 就直接从a移动到c
        return;
    }
    hanoi(count - 1, a, c, b); // 把a前面count-1的盘子先通过c移动到b上面
    move(a, c);                // 把a剩下的那个盘子移到c上
    hanoi(count - 1, b, a, c); // 把b的盘子通过a移动到c上
}
void move(char x, char y)
{
    printf("%c->%c\n", x, y);
}